package com.ctbri.containerindepth;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;

import com.ctbri.util.Countries;

public class Ex7 {

	public static void main(String[] args) {
		ArrayList<String> al = new ArrayList<>(Countries.names(25));
		LinkedList<String> ll = new LinkedList<>(Countries.names(25));
		Iterator<String> ali = al.iterator();
		Iterator<String> lli = ll.iterator();
		
		while(ali.hasNext())
			System.out.print(ali.next() + " ");
		System.out.println();
		while(lli.hasNext())
			System.out.print(lli.next() + " ");
		System.out.println();
		
		ListIterator<String> alli = al.listIterator(al.size());
		ListIterator<String> llli = ll.listIterator(ll.size());
		while(alli.hasPrevious() /*&& llli.hasPrevious()*/) {
			alli.add(llli.previous());
			alli.previous();
			alli.previous();
		}
		System.out.println(al);
	}

}
